{
	template:`
	<a-page-header title="设置菜单">
		<template #extra>
			<a-button type="primary" @click="save();">保存</a-button>
			<m-back @click="back(false);">关闭</m-back>
		</template>
		<a-card :hoverable="true">
			<a-tree checkable :tree-data="dataList" v-model:expandedKeys="expandedKeys" v-model:checkedKeys="checkedKeys">
				<template #title="obj">
					<div><m-icon :name="obj.icon" size="18"></m-icon>{{obj.title}} <small>{{obj.desc}}</small></div>
				</template>
			</a-tree>
		</a-card>
	</a-page-header>
	`,
	props: ['localeZh','param','parentVue'],
	data:function(){
		return {
			dataList:[],
			checkedKeys:[],
			expandedKeys:[]
		};
	},
	mounted(){
		this.requestData("action/manage/groupMenuLink/getGroupMenuLink",
			{adminGroupOid:this.param.groupOid},
			function(json){
				if(json.code==0){
					var map=json.map;
					this.requestData("action/manage/groupMenuLink/getAllMenuList",
						{},
						function(data){
							if(data.code==0){
								var ek=[];
								for(var k in data.modules){
									var module=data.modules[k];
									var dis=map[k]&&map[k].length==1||module.disabled;
									var m1=[];
									for(var k1 in module.menus){
										var menu1=module.menus[k1];
										var dis1=map[k1]&&map[k1].length==1||menu1.disabled;
										var m2=[];
										for(var k2 in menu1.menus){
											var menu2=menu1.menus[k2];
											var dis2=map[k2]&&map[k2].length==1||menu2.disabled;
											m2.push({key:k2,title:menu2.name,icon:menu2.icon,desc:menu2.desc,disableCheckbox:dis2,slots:{title:'title'}});
											if(map[k2]) this.checkedKeys.push(k2);
										}
										m1.push({key:k1,title:menu1.name,icon:menu1.icon,desc:menu1.desc,disableCheckbox:dis1,children:m2,slots:{title:'title'}});
										if(map[k1]&&m2.length==0) this.checkedKeys.push(k1);
										ek.push(k1);
									}
									this.dataList.push({key:module.oid,title:module.name,icon:module.icon,disableCheckbox:dis,children:m1,slots:{title:'title'}});
									if(map[module.oid]&&m1.length==0) this.checkedKeys.push(module.oid);
									ek.push(module.oid);
								}
								this.dataList=[...this.dataList];
								this.$nextTick(()=>{
									this.expandedKeys=ek;
								});
							}else{
								this.remind().error(data.msg);
							}
						}.bind(this)
					);
				}else{
					this.remind().error(data.msg);
				}
			}.bind(this)
		);
	},
	methods:{
		save:function(){
			var ls=[];
			for(var i=0,len=this.checkedKeys.length;i<len;i++){
				var key=this.checkedKeys[i];
				ls.push({module:{oid:key.substring(0,1)},menu:{oid:key},adminGroup:{oid:this.param.groupOid}});
			}
			this.requestData("action/manage/groupMenuLink/saveAll",
				{"adminGroupOid":this.param.groupOid,"modelList":ls},
				function(data){
					if(data.code!=0){
						this.remind().error(data.msg);
					}else{
						this.remind().success(data.msg);
						this.back(true);
					}
				}.bind(this)
			);
		},
	}
}